//
// Created by de on 3/30/21.
//

#include "TErrorState.h"

E_State TErrorState::init() {
    return Normal;
}

E_State TErrorState::prepare() {
    return Normal;
}

E_State TErrorState::start() {
    return Normal;
}

E_State TErrorState::reset() {
//    spdlog::info("Stop state : reset running ");
    std::this_thread::sleep_for(std::chrono::seconds(3));
    ForceStateData data = node->getDeviceControlStateStatus();
//    switch (data.errCodeInfoData.Err_level){
//        //不可恢复异常
//        case 1:
//            spdlog::info("sendDeviceForceReset ");
//        //可恢复异常
//        case 2:
//            return Normal;
//        //可人工恢复异常
//        default:
//            return Normal;
//    }
    return node->sendDeviceForceReset()== true? Normal: Error;
}

E_State TErrorState::stop() {
//    spdlog::info("Stop state : stop running");
//    std::this_thread::sleep_for(std::chrono::seconds(3));
    node->sendDeviceStop();
    return Normal;
}

StateStatus TErrorState::getCurrentState() {
    return RunningState;
}

bool TErrorState::clearWarn() {
    return PlaformStateAbstract::clearWarn();
}
